



import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:luckin_demo/routes/app_routes.dart';
import 'package:luckin_demo/routes/get_pages.dart';

/// youtube Devefy
/// git:https://github.com/iampawan/FlutterExampleApps?tab=readme-ov-file  15demo
void main()  => runApp(
  new GetMaterialApp(
    theme: ThemeData(
       primaryColor: Colors.red,
    ),
    debugShowCheckedModeBanner: false,
    home: SplashScreen() ,
    initialRoute: '/',
    getPages: AppPages.routes,
  )
);

class SplashScreen extends StatefulWidget {
  const SplashScreen({super.key});


  @override
  State<SplashScreen> createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    new Future.delayed(Duration(seconds: 3), newHomePage);
    
  }
  void newHomePage() {
    Get.toNamed(AppRoutes.Mine);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        fit: StackFit.expand,
        children: [
          Container(
            decoration: BoxDecoration(color: Colors.red),
          ),
          Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Expanded(
                  flex: 3,
                  child: Container(
                    child: const Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        CircleAvatar(
                          backgroundColor: Colors.white,
                          radius: 50.0,
                          child: Icon(
                            Icons.shopping_cart,
                            color: Colors.greenAccent,
                            size: 50.0,
                          ),
                        ),
                        Padding(padding: EdgeInsets.only(top: 10.0)),
                        Text(
                          'FlutKart',style: TextStyle(
                          color: Colors.white,
                          fontSize: 24.0,
                          fontWeight: FontWeight.bold
                        ),
                        ),
                      ],
                    ),
                  ),
              ),
              Expanded(flex: 1,
              child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  CircularProgressIndicator(),
                  Padding(padding: EdgeInsets.only(top: 20.0)),
                  Text('Online Store \nFor Everyone',
                    style: TextStyle(color: Colors.white,fontSize: 18.0,fontWeight: FontWeight.bold),),

                  Container(
                    alignment: Alignment.topRight,
                    // padding: const EdgeInsets.fromLTRB(0.0, 45.0, 10.0, 0.0),
                    child: MaterialButton(
                      child:  Text(
                        "跳过",
                        textAlign: TextAlign.center,
                        style:  TextStyle(color: Colors.white),
                      ),
                      // StadiumBorder椭圆的形状
                      shape:  StadiumBorder(),
                      onPressed: () {
                        newHomePage();
                      },
                    ),
                  ),
                ],
              ),

              )

            ],
          )
        ],
      ),
    );
  }
}


